package com.example.demo.widget.chart

import android.graphics.PointF
import android.graphics.RectF
import android.support.annotation.ColorInt

/**
 * 统计图Item
 *
 * @author wangheng
 */
data class ChartItem(val title: String, val subTitle: String, @ColorInt val color: Int, val value: Float, val onlyDrawColor: Boolean = false){
    companion object {
        const val PART_1 = 1
        const val PART_2 = 2
    }
    val titleRect = RectF()
    val subTitleRect = RectF()
    // 注释第一条线段开始点
    var firstPoint = PointF()
    // 注释第一条线段结束点
    var secondPoint = PointF()

    // 注释第二条线段结束点
    var thirdPoint = PointF()

    var startAngle = 0f
    var swipeAngle = 0f

    var partInChart = PART_1

    fun calculatePiePartInChart() {
        val angle = startAngle + swipeAngle / 2f
        partInChart = when{
            angle >= -90 && angle < 90 -> PART_1
            angle >= 90 && angle < 270 -> PART_2
            else -> PART_1
        }
    }

    fun calculateSemicirclePartInChart() {
        val angle = startAngle + swipeAngle / 2f
        partInChart = when{
            angle <= -90 -> PART_1
            else -> PART_2
        }
    }

    fun setSecondPointValue(point: PointF){
        secondPoint.x = point.x
        secondPoint.y = point.y
    }

}